package com.wuba.rxjavademo.lyz.day0602;

import com.wuba.rxjavademo.lyz.BaseDemo;

import rx.Observable;
import rx.Subscriber;
import rx.functions.Action0;
import rx.schedulers.Schedulers;

/**
 * Created by liyaxing on 2016/6/2.
 */
public class Demo01 extends BaseDemo {

    public static void main(String[] ss){

        print("position 0 : threadid : " + Thread.currentThread().getId());
        Observable.create(new Observable.OnSubscribe<Object>() {
            @Override
            public void call(Subscriber<? super Object> subscriber) {
                print("position 1 : threadid : " + Thread.currentThread().getId());
                subscriber.onNext(1);
                subscriber.onCompleted();
            }
        }).doOnSubscribe(new Action0() {
            @Override
            public void call() {
                print("position 2 : " + Thread.currentThread().getId());
            }
        }).subscribeOn(Schedulers.newThread()).subscribe() ;

        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }


    }


}
